//
//  HierarchicalNamedObjectSibling.m
//  pics
//
//  Created by Daniel Braun on 05/10/07.
//  Copyright 2007 __MyCompanyName__. All rights reserved.
//

#import "HierarchicalNamedObjectSibling.h"


@implementation HierarchicalNamedObjectSibling
- (void) dealloc {
	[nextObject release];
	[prevObject release];
	[super dealloc];
}

- (void) setNextObject: (HierarchicalNamedObjectSibling*)v
{
	[nextObject release];
	nextObject=[v retain];
}
- (void) setPrevObject: (HierarchicalNamedObjectSibling*)v
{
	[prevObject release];
	prevObject=[v retain];
}

- (void) setChildren:(NSMutableArray *)a
{
	[super setChildren:a];
	unsigned int i, count = [children count];
	for (i = 0; i < count-1; i++) {
		HierarchicalNamedObjectSibling * p = [children objectAtIndex:i];
		HierarchicalNamedObjectSibling * n = [children objectAtIndex:i+1];
		[p setNextObject:n];
		[n setPrevObject:p];
	}
}

- (void) addChild:(id)c
{
	HierarchicalNamedObjectSibling *p=nil;
	if ([children count]) {
		p=[children lastObject];
		[p setNextObject:c];
		[c setPrevObject:p];
	}
	[super addChild:c];
}

- (id) nextSiblingObject
{
	return nextObject;
}


- (id) prevSiblingObject
{
	return nextObject;
}


@end
